//
//  HomeBannerDetailsController.m
//  ArtDog
//
//  Created by dllo on 16/9/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "HomeBannerDetailsController.h"
#import "HLMacro.h"
#import "ZWYNetTool.h"
#import "BannerTypeFourModel.h"

@interface HomeBannerDetailsController ()<UIWebViewDelegate>

@property (nonatomic, strong) BannerTypeFourModel *typeFourModel;

@end

@implementation HomeBannerDetailsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)handleTypeFourData
{
    [ZWYNetTool GET:_urlString andBody:nil andHeader:HOSTHEADER andResponse:ZWYJSON andSuccessBlock:^(id result) {
        _typeFourModel = [BannerTypeFourModel modelWithDic:result[@"data"]];
        [self createWebView:_typeFourModel.topicDetailUrl];
    } andFailureBlock:^(NSError *error) {
        NSLog(@"%@", error);
    }];
}

- (void)setWebString:(NSString *)webString
{
    _webString = webString;
    [self createWebView:webString];
}

- (void)createWebView:(NSString *)webString
{
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    [self.view addSubview:webView];
    webView.delegate = self;
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:webString]];
    [webView loadRequest:request];

}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    self.isHaveActivity = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    self.isHaveActivity = NO;
}

- (void)setUrlString:(NSString *)urlString
{
    _urlString = urlString;
    self.isHaveActivity = YES;
    [self handleTypeFourData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
